package com.csaba.connector.citi;

import com.csaba.connector.ServiceException;
import com.csaba.connector.citi.model.CitiRequestFactory;
import com.csaba.connector.citi.model.CitiSession;
import com.csaba.connector.model.Session;
import com.csaba.connector.service.LogoutService;

public class CitiLogoutService implements LogoutService
{
	//private final static Logger logger = LoggerHelper.getDefaultLogger();

	@Override
	public void execute( final Session session ) throws ServiceException
	{
		if ( !( session instanceof CitiSession ) )
			throw new ServiceException("Unsupported session for Citi services: " + session.getClass().getName());

		final CitiSession citiSession = (CitiSession) session;

		//Logout - get
		//https://home1hu.cbol.citibank.hu/CappWebAppHungary/capp/action/signOff.do?_TS=1226501055820
		final String result = citiSession.doGetWithTimeStamp(CitiRequestFactory.HOMEBANK_URL_BASE
				+ CitiRequestFactory.REQUEST_LOGOUT_TS_NEEDED);
		citiSession.debugFile("logout", result);
	}

}
